home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / sound / sample20.zip / SAMPLER.PAS < prev    next >
Pascal/Delphi Source File  |  1989-05-20  |  55KB  |  1,266 lines

  1.  
  2.  
  3. Program analog_sound_sampler_with_editor;
  4.  
  5. {$A+,B-,D-,E+,F-,I+,L+,N-,O+,R-,S+}
  6. {$M 16384,0,655360}
  7. { $define debug}
  8. {$ifdef debug}
  9. {$r+}
  10. {$endif}
  11. {$v-}
  12.  
  13. Uses
  14.   dos, crt, graph, rm, menus, fonts, drivers, mousfunc, turbmous,printer;
  15.  
  16. { $define pwm}
  17. {$define sample}
  18.  
  19. {$l samplasm}
  20.  
  21. Const
  22.   {$ifndef pwm}
  23.   titlestring    = 'Sampler  V2.0    (C) R.McKenzie 1989';
  24.   {$endif pwm}
  25.   {$ifdef pwm}
  26.      titlestring = 'PWM Sampler 2.0 (C) R.McKenzie 1989';
  27.   {$endif pwm}
  28.  
  29. (*
  30.  
  31.                    (C) Copyright 1989 by Rowan McKenzie
  32.  
  33.                   You may copy these files  or use the source  code  only
  34.         for non-profit purposes. Please contact me if you wish to use any
  35.         part of the package for commercial purposes.
  36.  
  37.                   Rowan McKenzie
  38.                   35 Moore Ave,
  39.                   Croydon 3136
  40.                   Vic, Australia
  41.  
  42.  
  43.   This program allows the manipulation and replay with chromatic intervals of
  44.     digital sound samples from the keyboard using a guitar fretboard or piano
  45.     keyboard layout. Pitch is determined by a fractional increment technique
  46.     and played through a D/A converter connected to a parallel port or through
  47.     the PC speaker using Pulse Width Modulation.
  48.  
  49.   To create the PWM speaker version, define pwm above, change the pwm
  50.     definition in the samplasm.asm file to true, reassemble samplasm.asm,
  51.     and recompile this file.
  52.  
  53.   To create the D/A version, define da above, change the pwm
  54.     definition in the samplasm.asm file to false, reassemble samplasm.asm,
  55.     and recompile this file.
  56.  
  57.   To use the D/A version, an 8 bit D/A converter will need to be connected
  58.     to the parallel printer port named in the SAMPLER.CNF file.
  59.  
  60.   To use the sample facility an autotriggering A/D converter will need be
  61.     appear at the same port address as the D/A converter, and define sample *)
  62.  
  63.  
  64.  
  65.  
  66. Const cnffilename = 'sampler.cnf';
  67.   clipboardfilename = '.\sampler.clp';
  68.  
  69.   lpt1           = $3bc;          {might be wrong order?}
  70.   lpt2           = $378;
  71.   lpt3           = $278;
  72.  
  73.   default_samplerate = 27;        {initial sample rate=27kHz}
  74.   blocksize      = 4096;          {size of blocks for blockread/write}
  75.  
  76.   bufflength      = $fe00;         {sample buffer size (<64k-16)}
  77.                                   {NOTE: this is the absolute minimum size
  78.                                    allowed here if compatibility between
  79.                                    versions is to be maintained}
  80.  
  81.   maxbeats       = 500;           {no. song elements allowed}
  82.   maxjumps       = 20;            {no. jumps allowed inside songs}
  83.   maxsymbols     = 15;            {no. symbols in songs allowed}
  84.   maxfiles       = 301;           {no. files allowed in directory list (set
  85.                                 according to how many will fit on directory
  86.                                 display +1)}
  87.  
  88.   bigemptystring = '                                                                            ';
  89.   esc            = #$1b;
  90.   introdelay     = 700;           {delay for user to read intro screen(x10ms)}
  91.  
  92.   dialogbcolor   = red;
  93.   dialogcolor    = white;
  94.   clickbcolor    = red;
  95.   clickcolor     = white;
  96.   screencolor    = green;
  97.   dirbcolor      = green;
  98.   dircolor       = black;
  99.   dirhcolor      = white;
  100.   panelcolor     = lightgreen;
  101.   wavecolor      = white;
  102.   waveboxcolor   = lightred;
  103.   hotcolor       = white;
  104.   hotbcolor      = lightblue;
  105.   titlecolor     = black;
  106.   tuningbcolor   = blue;
  107.   tuningcolor    = white;
  108.   timerbcolor    = green;
  109.   timercolor     = white;
  110.   drawcolor      = yellow;
  111.  
  112.   cornersize     = 20;            {size of corner arc}
  113.   arrowxsize     = 8;             {width of arrow pointers}
  114.   arrowysize     = 9;             {height       "         }
  115.   arrowxoff      = 4;            {offset to center of arrow (arrowxsize div 2)}
  116.   arrowpoints    = 8;             {no. points in arrow}
  117.  
  118.  
  119.  
  120.   {patterns for arrow pointers}
  121.  
  122.   uparrowshape : Array[1..arrowpoints] Of pointtype =
  123.   ((x : 4; y : 0), (x : 0; y : 4), (x : 3; y : 4), (x : 3; y : 9),
  124.    (x : 5; y : 9), (x : 5; y : 4), (x : 8; y : 4), (x : 4; y : 0));
  125.   downarrowshape : Array[1..arrowpoints] Of pointtype =
  126.   ((x : 104; y : 9), (x : 100; y : 5), (x : 103; y : 5), (x : 103; y : 0),
  127.    (x : 105; y : 0), (x : 105; y : 5), (x : 108; y : 5), (x : 104; y : 9));
  128.  
  129.   tuningshapepoints = 4;
  130.   tuningrshape : Array[1..tuningshapepoints] Of polypoint =
  131.   ((x : 10; y : 8), (x : 0; y : 12), (x : 0; y : 4), (x : 10; y : 8));
  132.   tuninglshape : Array[1..tuningshapepoints] Of polypoint =
  133.   ((x : 0; y : 8), (x : 10; y : 12), (x : 10; y : 4), (x : 0; y : 8));
  134.  
  135.   introyoff      = 3;             {intro information position}
  136.   plotxoffset    = arrowxoff;     {indent from edge of screen for wave}
  137.   dirnamefieldwidth = 14;         {field width for directory names}
  138.  
  139.  
  140.   {modified codes to represent special keys in one byte}
  141.  
  142.   spctrl = #128; splshift = #129; sprshift = #130; spalt = #131; spcaps = #132;
  143.   spnum = #133; spscroll = #134; sphome = #135; spsys = #136; spuparrow = #137;
  144.   sppgup = #138; spprtsc = #139; spleftarrow = #140; sp5 = #141;
  145.   sprightarrow = #142; spminus = #143; spend = #144; spdownarrow = #145;
  146.   sppgdn = #146; spplus = #147; spins = #148; spdel = #149; spf1 = #151;
  147.   spf2 = #152; spf3 = #153; spf4 = #154; spf5 = #155; spf6 = #156; spf7 = #157;
  148.   spf8 = #158; spf9 = #159; spf10 = #160;
  149.  
  150.  
  151.   {the following arrays map the keyboard to a set of notes (guitar or piano)
  152.     where -13 is an invalid letter}
  153.  
  154. Type kbdmaptype = Array[''''..']'] Of Integer;
  155.  
  156. Const kbdmapguitar : kbdmaptype =
  157.   ( {'} 3, -13, -13, -13, -13, -5, 13, -4, -3, 12, 3, 4, 5, 6, 7, 8,
  158.    9, 10, 11, -13, 2, -13, 14, -13, -13, -13,
  159.    {A} -7, -8, -10, -5, 0, -4, -3, -2, 5, -1, 0, 1, -6, -7, 6, 7,
  160.    -2, 1, -6, 2, 4, -9, -1, -11, 3, -12, 8, 15, 9);
  161.  
  162.  
  163.   kbdmappiano : kbdmaptype =
  164.   ( {'} 10, -13, -13, -13, -13, 5, 20, 7, 9, 18, 3, -13, 6, 8, 10, -13,
  165.    13, 15, -13, -13, 8, -13, 22, -13, -13, -13,
  166.    {A} -13, 0, -3, -4, 7, -2, -13, 1, 16, 3, -13, 6, 4, 2, 17, 19, 4,
  167.    9, -6, 11, 14, -1, 5, -5, 12, -7, 21, -13, 23);
  168.  
  169.  
  170.   {the following table maps scan codes to ascii values}
  171.  
  172.   scanmap : Array[0..255] Of Char =
  173.  
  174.   ( {0} #0, esc, '1', '2', '3', '4', '5', '6', '7', '8',
  175.    {10} '9', '0', '-', '=', #8, #9, 'Q', 'W', 'E', 'R',
  176.    {20} 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', #13, spctrl,
  177.    {30} 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';',
  178.    {40} '''', '`', splshift, '\', 'Z', 'X', 'C', 'V', 'B', 'N',
  179.    {50} 'M', ',', '.', '/', sprshift, #0, spalt, ' ', spcaps, spf1,
  180.    {60} spf2, spf3, spf4, spf5, spf6, spf7, spf8, spf9, spf10, spnum,
  181.    {70} spscroll, sphome, spuparrow, sppgup, spminus, spleftarrow, sp5,
  182.    sprightarrow, spplus, spend,
  183.    {80} spdownarrow, sppgdn, spins, spdel, #0, #0, #0, #0, #0, #0,
  184.    {90} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  185.    {100} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  186.    {110} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  187.    {120} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  188.    {130} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  189.    {140} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  190.    {150} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  191.    {160} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  192.    {170} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  193.    {180} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  194.    {190} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  195.    {200} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  196.    {210} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  197.    {220} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  198.    {230} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  199.    {240} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
  200.    {250} #0, #0, #0, #0, #0, #0);
  201.  
  202.  
  203. Type
  204.   bufferp        = ^buffertype;
  205.   buffertype =
  206.            Array[0..bufflength] Of Byte;      {holds samples, plus overflow space}
  207.   dummyp         = ^dummytype;
  208.   dummytype      = Array[1..128] Of Byte; {overflow area for buffers}
  209.   directory_type = Array[1..maxfiles] Of String[12]; {holds directory entries}
  210.   songentry = Record              {holds one entry of a song file}
  211.                 note        : R